1 // Equipo Poncho, Carriel y Ruana
22 template <class T
> string
toStr(const T
&x
)
23 { stringstream s
; s
<< x
; return s
.str(); }
24 template <class T
> int toInt(const T
&x
)
25 { stringstream s
; s
<< x
; int r
; s
>> r
; return r
; }
27 #define For(i, a, b) for (int i=(a); i<(b); ++i)
28 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
29 #define D(x) cout << #x " = " << (x) << endl;
31 const double EPS
= 1e-9;
33 int cmp(double x
, double y
= 0, double tol
= EPS
) {
34 return (x
<= y
+ tol
) ? (x
+ tol
< y
) ? -1 : 0 : 1;
37 #define INPUT_FILE "problemname"
41 freopen(INPUT_FILE
".in", "r", stdin
);
44 vector
<pair
<long long, long long>> stations
;
46 while(cin
>> l
>> gases
) {
49 if(l
== 0 and gases
== 0) break;
50 for(long long i
=0; i
<g
; i
++) {
56 stations
.push_back(make_pair(li
, ls
);
58 sort(stations
.begin(), stations
.end());
60 for(long long i
= 0; i
<l
;) {
62 for(long long g
; g
<stations
.length(); ++g
) {
63 if (stations
[g
].first
<= i
and stations
[g
].second
> i
) {
64 fin
= max(fin
, stations
[g
].second
);
66 if (stations
[g
].first
> i
) break;
75 cout
<< gases
-usados
<< endl
;